package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.crfZero;
import com.ruoyi.system.service.IcrfZeroService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 术前筛选区，v0Controller
 * 
 * @author miao
 * @date 2024-06-26
 */
@RestController
@RequestMapping("/crfZero/crfZero")
public class crfZeroController extends BaseController
{
    @Autowired
    private IcrfZeroService crfZeroService;

    /**
     * 查询术前筛选区，v0列表
     */
    @GetMapping("/list")
    public TableDataInfo list(crfZero crfZero)
    {
        startPage();
        List<crfZero> list = crfZeroService.selectcrfZeroList(crfZero);
        return getDataTable(list);
    }

    /**
     * 根据受试者id查询填写的v0
     */
    @GetMapping("/list/tid")
    public crfZero listByTid(int id)
    {
        return crfZeroService.selectBytid(id);
    }

    /**
     * 导出术前筛选区，v0列表
     */
    @Log(title = "术前筛选区，v0", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, crfZero crfZero)
    {
        List<crfZero> list = crfZeroService.selectcrfZeroList(crfZero);
        ExcelUtil<crfZero> util = new ExcelUtil<crfZero>(crfZero.class);
        util.exportExcel(response, list, "术前筛选区，v0数据");
    }

    /**
     * 获取术前筛选区，v0详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(crfZeroService.selectcrfZeroById(id));
    }

    /**
     * 新增术前筛选区，v0
     */
    @Log(title = "术前筛选区，v0", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody crfZero crfZero)
    {
        return toAjax(crfZeroService.insertcrfZero(crfZero));
    }

    /**
     * 修改术前筛选区，v0
     */
    @Log(title = "术前筛选区，v0", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody crfZero crfZero)
    {
        return toAjax(crfZeroService.updatecrfZero(crfZero));
    }

    /**
     * 删除术前筛选区，v0
     */
    @Log(title = "术前筛选区，v0", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crfZeroService.deletecrfZeroByIds(ids));
    }
}
